/*
 * @Author: KKKKKK
 * @Date: 2021-01-10 12:07:44
 * @LastEditors: KKKKKK
 * @LastEditTime: 2021-01-10 12:07:45
 */
import axios from './config'
import url from './url'
const baseUrl = process.env.VUE_APP_BASE_URL

/* 菜单 */
// 查询一级目录
const menuLevel1 = (params) => axios.get(baseUrl + url.menu.level1, { params })

// 查询菜单树
const menuTree = (params) => axios.get(baseUrl + url.menu.menuTree, { params })

// 新增菜单
const menuCreate = (params) => axios.post(baseUrl + url.menu.create, params)

// 删除菜单
const menuDeleteInfo = (id) => axios.delete(baseUrl + url.menu.deleteInfo + `/${id}`)

// 根据菜单id获取数据
const menuLoad = (id) => axios.get(baseUrl + url.menu.load + `/${id}`)

// 修改菜单
const menuUpdate = (params, id) => axios.post(baseUrl + url.menu.update + `/${id}`, params)

// 批量删除角色菜单授权信息
const menuDeletes= (params) => axios.post(baseUrl + url.menu.deletes, params)

// 进行角色菜单授权
const menuGranprivile= (params) => axios.post(baseUrl + url.menu.granprivile, params)

// 分页获取未授权菜单
const menuNtprivipage = (params) => axios.get(baseUrl + url.menu.ntprivipage, { params })

// 分页获取已授权菜单
const menuPage = (params) => axios.get(baseUrl + url.menu.page, { params })

// 登录查询用户菜单权限
const menuSysMenuLoad = (userId, params) => axios.get(baseUrl + url.menu.sysMenuLoad + `/${userId}`, { params })

export default {
  menuLevel1,
  menuTree,
  menuCreate,
  menuDeleteInfo,
  menuLoad,
  menuUpdate,
  menuDeletes,
  menuGranprivile,
  menuNtprivipage,
  menuPage,
  menuSysMenuLoad
}
